using System.Collections.Generic;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAccess;
using EPiServer.Security;

namespace OpenWaves.EPiServer.Abstractions
{
    public class DataFactoryWrapper : IDataFactory
    {
        public PageData GetPage(PageReference pageLink)
        {
            return DataFactory.Instance.GetPage(pageLink);
        }

        public PageData GetPage(PageReference pageLink, ILanguageSelector languageSelector)
        {
            return DataFactory.Instance.GetPage(pageLink, languageSelector);
        }

        public IEnumerable<PageData> GetChildren(PageReference pageLink, ILanguageSelector languageSelector = null)
        {
            if (languageSelector == null)
            {
                languageSelector = LanguageSelector.AutoDetect(false);
            }

            return DataFactory.Instance.GetChildren(pageLink, languageSelector);
        }

        public PageReference Save(PageData page, SaveAction action)
        {
            return DataFactory.Instance.Save(page, action);
        }

        public PageReference Save(PageData page, SaveAction action, AccessLevel accessLevel)
        {
            return DataFactory.Instance.Save(page, action, accessLevel);
        }
    }
}